import Vue from 'vue'
import VueRouter from 'vue-router'

// 路由懒加载
const Login = () => import('@/views/Login/index.vue')
const Layout = () => import('@/views/Layout/index.vue')
const Home = () => import('@/views/Home/index.vue')
const Article = () => import('@/views/Article/index.vue')
const Publish = () => import('@/views/Publish/index.vue')

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    alias: '/login',
    name: 'Login',
    component: Login
  },
  {
    path: '/layout',
    redirect: '/layout/home',
    component: Layout,
    children: [
      {
        path: '/layout/home',
        component: Home
      },
      {
        path: '/layout/article',
        component: Article
      },
      {
        path: '/layout/publish',
        component: Publish
      }
    ]
  }
  // {
  //   path: '/about',
  //   name: 'About',
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  // }
]

const router = new VueRouter({
  routes
})

export default router
